<?php
/* $Id$ */
use Buan\Config;
use Buan\SystemLog;
use Buan\View;
$urlRoot = Config::get('ext.Scribble.urlRoot');
View::getGlobalView()->addStylesheets("{$urlRoot}/css/global-view/system-log.css");

// Sort all messages by type
$systemLog = SystemLog::getAll();
$messages = array();
foreach($systemLog as $entry) {
	$type = $entry->getTypeString();
	if(!isset($messages[$type])) {
		$messages[$type] = array($entry);
	}
	else {
		$messages[$type][] = $entry;
	}
}
?>

<?php if(!empty($messages)): ?>
	<ul id="system-log">
	<?php foreach($messages as $type=>$entries): ?>
		<li class="alert-<?php echo $type; ?>">
			<h4><?php $this->html->e(strtoupper($type)); ?></h4>
			<ul>
			<?php foreach($entries as $entry): ?>
				<li><?php $this->html->e($entry->getMessage()); ?></li>
			<?php endforeach; ?>
			</ul>
		</li>
	<?php endforeach; ?>
	</ul>
<?php endif; ?>